<template>
  <view class="page">

    <uni-card :title="form.title" :sub-title="form.authorName" :extra="form.createTime">
      <text class="uni-body">
        <u-parse :content="form.content"></u-parse>
      </text>
    </uni-card>
  </view>
</template>

<script>
  import {
    getArticle,
  } from '@/api/system/article.js'
  export default {
    data() {
      return {
        cid: undefined,
        form: {},
      }
    },
    onShow() {
      this.getList(this.cid)
    },
    onLoad(e) {
      this.cid = e.cid
      this.getList(e.cid)
    },
    methods: {
      handleEdit(cid) {
        uni.navigateTo({
          url: '/pages/essay/publish?cid=' + cid
        })
      },
      getList(cid) {
        uni.showLoading({
          title: 'loading...'
        });
        getArticle(cid).then(res2 => {
          const {
            code,
            data
          } = res2
          if (code == 200) {
            this.form = data
          }
        })
        uni.stopPullDownRefresh()
      },
      /**
       * 下拉刷新回调函数
       */
      onPullDownRefresh() {
        this.getList(this.cid)
      },
    }
  }
</script>

<style scoped lang="scss">
  .page {
    .item {
      color: #ccc;
      margin: 20rpx 0;
    }
  }
</style>